<template>
	<view>
		<navbar :isback="true" title="我的收藏"></navbar>
		<u-sticky bgColor="#fff" customNavHeight="44">
			<view class="con">
				<view class="con__tip">
					<u-icon name="/static/my/gt.png" size="33rpx"></u-icon>
					<view class="con__tip__text">
						再次点击收藏图标，可以取消当前收藏信息
					</view>
				</view>
			</view>
		</u-sticky>
		<u-loading-page icon-size="100rpx" :loading="loading" loading-text="驼乡生活信息超市"></u-loading-page>
		<view class="" v-if="!loading">
			<view class="" v-if="msglist.length>0">
				<msgitem :item="item" v-for="(item,index) in msglist" :key="index" @dianz='dianz' v-if="item.pay_state==2"></msgitem>
			</view>
			<view class="" v-else style="padding-top: 50rpx;">
				<u-empty mode="list" text="暂无消息">
				</u-empty>
			</view>
		</view>
		
		<u-safe-bottom></u-safe-bottom>
		<view class="kf">
			<button class="u-reset-button" open-type="contact">
				<image src="/static/xishi/kf.png" class="kficon" mode=""></image>
			</button>
		</view>
	</view>
</template>

<script>
	import {
		BASE_URL
	} from '@/api/config';
	import user from '@/api/_user.js'
	export default {
		data() {
			return {
				msglist: [],
				loading:true
			};
		},
		methods:{
			getlist(){
				user.myCollect().then(res=>{
					if(res.data.code==1){
						this.msglist=res.data.data
						this.loading=false
						this.msglist.map(t => {
							t.imags = []
							t.imag = t.ad_images.split(',')
							if (t.imag[0] == '') {
								t.imag = []
							}
							t.imag.map(t1 => {
								t.imags.push(BASE_URL + t1)
							})
						})
						this.$forceUpdate()
					}
				})
			},
			dianz(e){
				console.log(e)
				if(!e){
					console.log('取消收藏')
					this.getlist()
				}
			}
		},
		onLoad() {
			this.getlist()
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #FAFAFA;
	}
.con{
	padding: 30rpx;
	&__tip{
		padding: 0 27rpx;
		height: 96rpx;
		background: #F7F7F9;
		border-radius: 15rpx;
		display: flex;
		align-items: center;
		&__text{
			font-family: PingFang SC;
			font-weight: 500;
			font-size: 26rpx;
			color: #1E1E1E;
			line-height: 36rpx;
			padding-left: 15rpx;
		}
	}
}
</style>
